<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="ww" uri="webwork" %>
	<input type="hidden" id="pwdLevelJs" name="pwdLevelJs" value="<ww:property value='pwdLevel'/>"/>
	<input type="hidden" id="realpwd" name="realpwd" value="<ww:property value='#session.sUser.password'/>"/>
	<input type="hidden" id="realreviewpwd" name="realreviewpwd" value="<ww:property value='#session.sUser.reviewPwd'/>"/>
	
	<div class="table_list_tab">
		<ww:link name="loginPwdDivTab" funcode="acl_user/updPasswordSetting" caption="修改登录密码"  onclick="showLoginPwdDivTab();"  href="javascript:;"></ww:link>
		<ww:link name="reviewPwdDivTab" funcode="acl_user/updReviewPwdSetting" caption="修改签章密码"  onclick="showReviewPwdDivTab();"  href="javascript:;"></ww:link>
		<ww:link name="personalDataTab" funcode="acl_user/updPersonalSetting" caption="修改个人资料"  onclick="showPersonalDataTab();"  href="javascript:;"></ww:link>
	</div>

		<form class="form-horizontal form-validateRe" id="updReviewPwdSetting_form" method="post" action="updReviewPwdSetting.action"  onsubmit="return $action.submit(this)">
			<input type="hidden" id="pwdLevel" name="pwdLevel" value="<ww:property value='pwdLevel'/>"/>
			<input type="hidden" id="reviewPwdHidden" name="reviewPwdHidden" value="<ww:property value='item.reviewPwd'/>" />
			<input type="hidden" id="reviewPwdTr" name="reviewPwdTr" />
			<input type="hidden" id="newReviewPwdTr" name="newReviewPwdTr" />
			<input type="hidden" id="repeatNewReviewPwdTr" name="repeatNewReviewPwdTr" />
				<div class="control-group">
						<label class="control-label" >原密码</label>
						<div class="controls">
							<input type="password" placeholder="请输入原密码" class="input-large" onfocus="reviewpasswordfocus()" onblur="reviewpasswordblur()" name="reviewPwd" id="reviewPwd" value="" maxlength="50" onKeyUp="onNewReviewPwdMouseMove();"/><!--  class="input-large required" -->
							<font id="reviewPasswordShowEm" color="red"></font>
						</div>
				</div>
				<div class="control-group">
						<label class="control-label"><span class="required">*</span>新密码</label>
						<div class="controls">
							<input type="password" placeholder="请输入6-16位新密码" name="newReviewPwd"  class="input-large required" maxlength="50"
								id="newReviewPwd" value="" onblur="hiddenReviewTable()" onkeyup="pwReviewStrength(this.value)"
								onfocus="pwReviewStrength(this.value)">
								<font id="newReviewPasswordShowEm" color="red" style="left: 16px;position: relative;"></font>
								<%--<div class="editpass_n flo_l"><em class="err" id="newReviewPasswordShowEm"></em></div>
								<div class="clear"></div>
							--%><%--<div id="newReviewPasswordShowEm"></div>
                            --%><table  style="display:none" id="hiddenReviewTable" border="0" cellpadding="0" cellspacing="0" class="passmsg"> 
                              <tr> 
                                <td id="strength_L1" class="l">弱</td>
                                <td id="strength_M1" class="m">中</td> 
                                <td id="strength_H1" class="h">强</td> 
                              </tr>
                            </table>
						</div>
				</div>
				<div class="control-group">
						<label class="control-label"><span class="required">*</span>确认密码</label>
						<div class="controls">
							<input type="password" placeholder="请再次输入新密码" class="input-large required" name="repeatNewReviewPwd" maxlength="50"
								id="repeatNewReviewPwd" value="" onKeyUp="hiddenReviewTable()" onblur="onRepeatNewReviewPwdMouseMove();" onfocus="repeatNewReviewPasswordfocus()">
								&nbsp;&nbsp;&nbsp;&nbsp;<font id="repeatNewReviewPwdFont" color="red"></font>
								<%--<div id="repeatNewReviewPwdFont" style="color:#ff0000;margin-top: -25px;margin-left: 240px; margin-right: 10px;">
                          						</div>
						--%></div>
				</div>
				<div class="set-btn" data-spy="affix" data-offset-top="200">
						<%--<button id="saveButton" class="btn save" type="submit">保存</button>
						--%>
						<a class="save btn" href="javascript:;" onclick="submitRe();" style="border: 0;background-color: #317caf;height: 21px;width: 26px">保存</a>
				</div>
		</form>

	  

<script>
var pwdLevel = $("#pwdLevelJs").val();
var password = true;
var loginStatusPwd = 1;
var loginStatusRe = 1;
var loginStatusPe = 1;

$(document).ready(function() { 
	$("#loginPwdDivTab").attr("class","");
    $("#reviewPwdDivTab").attr("class","active");
    $("#personalDataTab").attr("class","");
}); 

function updReviewPwd(data){
	//debugger;
	navTabAjaxDone(data);
	if(data.result!=0){ 
		  $("#reviewPwd").val("");
		  $("#newReviewPwd").val("");
		  $("#repeatNewReviewPwd").val("");
		  $("#newReviewPasswordShowEm").html("");
		  $("#repeatNewReviewPwdFont").html("");
		  $css.alert(data.msg);
	}else{
		$css.tip(data.msg);
		$.cssTab.focus().parent().parent().cssTab('closeCurrent');
	}
}
function updPassword(data){
	navTabAjaxDone(data);
	if(data.result!=0){ 
		  $("#password").val("");
		  $("#newPassword").val("");
		  $("#repeatNewPassword").val("");
		  $("#newPasswordShowEm").html("");
		  $("#repeatPasswordShow1").html("");
		  $css.alert(data.msg);
		  
	}else{
		$css.tip(data.msg);
		$.cssTab.focus().parent().parent().cssTab('closeCurrent');
	}
}

function submitRe(){
	//debugger;
	if($("#newReviewPasswordShowEm").html() == "" && $("#repeatNewReviewPwdFont").html() == ""){
		if($("#reviewPwdHidden").val() != "") $("#reviewPwdTr").val(md5($("#reviewPwd").val()));
		$("#newReviewPwdTr").val(md5($("#newReviewPwd").val()));
		$("#repeatNewReviewPwdTr").val(md5($("#repeatNewReviewPwd").val()));
		$("#updReviewPwdSetting_form").submit();
	}else{
		loginStatusRe = 2;
		if($("#newReviewPasswordShowEm").html() != ""){
			$("#newReviewPwd").focus();
		}else if($("#repeatNewReviewPwdFont").html() != ""){
			$("#repeatNewReviewPwd").focus();
		}
	}
}


function CharMode(iN){
	if (iN>=48 && iN <=57) return 1; 
	if (iN>=65 && iN <=90) return 2; 
	if (iN>=97 && iN <=122) return 4; 
} 
function bitTotal(num){ 
	modes=0; 
	for (i=0;i<4;i++){
		if (num & 1) modes++; 
		num>>>=1; 
	} 
	return modes; 
} 
function checkStrong(sPW){ 
	if (sPW.length<=9) return 1; 
	Modes=1; 
	for (i=0;i<sPW.length;i++){ 
		Modes|=CharMode(sPW.charCodeAt(i)); 
	} 
	return bitTotal(Modes); 
} 


//校验签章密码
var  S_levelReview;
function pwReviewStrength(pwd){
	if($("#newReviewPwd").val() != ""){
		var reg=/^[A-Za-z0-9~`!@#$%^&*()_+\'{}<>?:,.;-=\"]+$/;
	    if(!reg.test($("#newReviewPwd").val())){
    		$("#newReviewPasswordShowEm").html("密码不允许使用空格！");
    	}else{
    		$("#newReviewPasswordShowEm").html("");
	    }
	}
	if($("#repeatNewReviewPwd").val() != ""){
		onRepeatNewReviewPwdMouseMove();
	}
	if(loginStatusRe == 2){
		hiddenReviewTable();
	}
	$("#hiddenReviewTable").attr("style","");
	if (pwd==null||pwd==''){ 
		S_levelReview = 0;
	}else {
		S_levelReview=checkStrong(pwd); 
		switch(S_levelReview) { 
		case 0:; 
		case 1: $("#strength_L1").addClass("cur"); $("#strength_M1").attr("class","m");$("#strength_H1").attr("class","h"); 
		break; 
		case 2: $("#strength_M1").addClass("cur"); $("#strength_L1").attr("class","l");$("#strength_H1").attr("class","h"); 
		break; 
		default: 
			$("#strength_H1").addClass("cur"); $("#strength_M1").attr("class","m");$("#strength_L1").attr("class","l"); 
		} 
	}
	return ; 
}
function onRepeatNewReviewPwdMouseMove() {
	if($("#newReviewPwd").val() != "" && $("#repeatNewReviewPwd").val() != ""){
	if ($("#newReviewPwd").val() != $("#repeatNewReviewPwd").val()) {
		$("#repeatNewReviewPwdFont").html("新密码与确认密码不一致");
	} else {
		$("#repeatNewReviewPwdFont").html("");
	}
	}
}
function hiddenReviewTable(){
	if($("#newReviewPwd").val().length > 16){
		$("#newReviewPasswordShowEm").html("密码长度是16位以内！");
	}else{
		$("#newReviewPasswordShowEm").html("");
		if(S_levelReview < pwdLevel && S_levelReview >0){
    		var msg = "";
    		if(pwdLevel == 2) msg="密码强度是中以上！";
    		if(pwdLevel == 3) msg="密码强度是强以上！";
    		$("#newReviewPasswordShowEm").html(msg);
    	}else{
    		$("#newReviewPasswordShowEm").html("");
    		$("#hiddenReviewTable").hide();
    	}
	}
	if($("#newReviewPwd").val() != ""){
		if($("#newReviewPwd").val() == $("#reviewPwd").val()){
			$("#newReviewPasswordShowEm").html("新密码与原密码不能相同！");
    	}
		var reg=/^[A-Za-z0-9~`!@#$%^&*()_+\'{}<>?:,.;-=\"]+$/;
	    if(!reg.test($("#newReviewPwd").val())){
			$("#newReviewPasswordShowEm").html("密码不允许使用空格！");
		}
	}
	
}
function onNewReviewPwdMouseMove(){
    if($("#newReviewPwd").val() != ""){
    	if($("#newReviewPwd").val() == $("#reviewPwd").val()){
    		$("#newReviewPasswordShowEm").html("新密码与原密码不能相同！");
    	}else{
    		$("#newReviewPasswordShowEm").html("");
    	}
    }
}

function reviewpasswordblur(){
	debugger;
	//debugger;
	if($("#reviewPwd").val() != ""){
	var realreviewpwd = $('#realreviewpwd').val();
	var reviewPwd = md5(md5($("#reviewPwd").val()));
	if(realreviewpwd != reviewPwd){
		$('#reviewPasswordShowEm').html("原密码输入错误！");
	}else{
		$('#reviewPasswordShowEm').html("");
	}
	}
}
function repeatNewReviewPasswordfocus(){
	$("#repeatNewReviewPwdFont").html("");
}
function reviewpasswordfocus(){
	$('#reviewPasswordShowEm').html("");
}

function showLoginPwdDivTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action',
	         active:true
			}
		);
}
function showReviewPwdDivTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action?type=2',
	         active:true
			}
		);
}
function showPersonalDataTab(){
		$('#tab-01').cssTab('reload',
			{title:'设置',
			 id:$.cssTab.focus().attr("id"),
			 url:'getUserSettings.action?type=3',
	         active:true
			}
		);
}
function changeDivContent() {
	if ($("#reviewPwdHidden").val() == "") {
		$("#reviewPwdDiv").html($("#setReviewPwdDiv").html());
		$("#setReviewPwdDiv").html("");
	}
}
changeDivContent();
</script>
